package com.example.backend.dao;

import com.example.backend.mapper.generator.AirPoMapper;
import com.example.backend.mapper.generator.HumidityPoMapper;
import com.example.backend.mapper.generator.TemperaturePoMapper;
import com.example.backend.mapper.po.AirPo;
import com.example.backend.mapper.po.AirPoExample;
import com.example.backend.mapper.po.HumidityPoExample;
import com.example.backend.mapper.po.TemperaturePoExample;
import com.example.backend.model.CloneFactory;
import com.example.backend.model.SensorData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AirDao {
    private AirPoMapper airPoMapper;

    @Autowired
    public AirDao(AirPoMapper airPoMapper) {
        this.airPoMapper = airPoMapper;
    }

    public List<SensorData> retrieve(AirPoExample example) {
        return this.airPoMapper.selectByExample(example).stream().map(po -> CloneFactory.copy(new SensorData(), po)).toList();
    }
}
